#ifndef __KERNEL_MEMORY_H
#define __KERNEL_MEMORY_H

#include "../lib/stdint.h"

#define PG_SIZE 0x1000
#define BITMAP_ADDR 0xc009a000
#define BITMAP_BOUND 0xc009e000
#define KERNEL_PHYSICAL_BOUND 0x00100000
#define KERNEL_BOUND 0xc0100000
#define PAGE_DIRECTORY 0xfffff000
#define PAGE_TABLE 0xfff00000
#define P 0x1 
#define RW 0x2
#define US 0x4

struct bitmap
{
	unsigned int size;
	unsigned int * start;
};

struct pool				//Physical memory pool.
{
	struct bitmap * bp;
	unsigned int *start;
	unsigned int size;
};

struct v_pool		//Vitrual memory pool.
{
	struct bitmap * bp;
	unsigned int * start;
};

enum selector
{
	kernel = 1,
	user = 2
};

static struct bitmap user_bitmap, kernel_bitmap, v_bitmap;
static struct pool kernel_pool, user_pool;
static struct v_pool virtual_pool;

void get_memsize(unsigned int* memsize_addr);
unsigned int memsize();
/*void bitmap_set(struct bitmap * bp, unsigned int *addr, unsigned int size);
void bitmap_init(struct bitmap * bp);
int32_t bitmap_search(struct bitmap * bp, uint32_t n);
void pool_set(struct pool * p, struct bitmap * bp, unsigned int *start, unsigned int size);
void bitmap_set_value(struct bitmap *bp, int32_t bit_location, uint32_t n, uint32_t value);
void v_pool_set(struct v_pool * vp, struct bitmap * bp, unsigned int * start);
void mem_init(void);
uint32_t * virtual_alloc(uint32_t n);
uint32_t * phy_pool_alloc(enum selector sel);
void map_page(uint32_t * vaddr, uint32_t * paddr);*/
uint32_t * malloc_pages(enum selector sel, uint32_t n);
void mem_init(void);

#endif